package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Hello world!
 *
 */
public class App {
    public static void main( String[] args ) {
        ApplicationContext ac = new AnnotationConfigApplicationContext(SpringConfig.class);
//      获取容器中的对象
        String[] beanDefinitionNames = ac.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
//      通过类型获取
        BookService bookService = ac.getBean(BookService.class);
        bookService.save();
    }
}
